/*     */ package com.newcrm.manager;
/*     */ 
/*     */ import com.newcrm.bean.ProductInfo;
/*     */ import com.newcrm.config.Config;
/*     */ import java.io.IOException;
/*     */ import java.io.UnsupportedEncodingException;
/*     */ import java.net.URLEncoder;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.jsoup.Connection;
/*     */ import org.jsoup.Jsoup;
/*     */ import org.jsoup.nodes.Document;
/*     */ 
/*     */ public class ReportLocalInfoManager
/*     */ {
/*  14 */   private static ReportLocalInfoManager manager = null;
/*     */   private static final String USERAGENT = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; Tablet PC 2.0)";
/*  18 */   private String localIP = null;
/*  19 */   private int localPort = 80;
/*     */ 
/*  25 */   private static Logger logger = Logger.getLogger(ReportLocalInfoManager.class.getName());
/*     */ 
/*     */   public static ReportLocalInfoManager getInstance()
/*     */   {
/*  50 */     if (manager == null) {
/*  51 */       manager = new ReportLocalInfoManager();
/*     */     }
/*  53 */     return manager;
/*     */   }
/*     */ 
/*     */   public void clear()
/*     */   {
/* 106 */     this.localIP = "";
/* 107 */     this.localPort = 0;
/*     */   }
/*     */ 
/*     */   public String report(String ip, int port, String path)
/*     */   {
/* 124 */     if ((ip == null) || (ip.trim().length() == 0)) {
/* 125 */       return null;
/*     */     }
/*     */ 
/* 128 */     if (("0.0.0.0".equals(ip)) || ("127.0.0.1".equals(ip))) {
/* 129 */       return null;
/*     */     }
/*     */ 
/* 132 */     if (port <= 0) {
/* 133 */       return null;
/*     */     }
/*     */ 
/* 136 */     if ((ip.equals(this.localIP)) && (port == this.localPort)) {
/* 137 */       return "1";
/*     */     }
/*     */ 
/* 141 */     String url = Config.getInstance().productInfo.accessIDServer;
/* 142 */     if ((url == null) || (url.trim().length() == 0)) {
/* 143 */       return null;
/*     */     }
/* 145 */     if (path == null) {
/* 146 */       path = "";
/*     */     }
/*     */ 
/*     */     try
/*     */     {
/* 153 */       url = url + "/report?ip=" + URLEncoder.encode(ip, "UTF-8") + 
/* 154 */         "&port=" + port + "&path=" + 
/* 155 */         URLEncoder.encode(path, "UTF-8");
/*     */     } catch (UnsupportedEncodingException e1) {
/* 157 */       return null;
/*     */     }
/*     */     try {
/* 160 */       String txt = Jsoup.connect(url).userAgent("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; Tablet PC 2.0)").timeout(10000)
/* 161 */         .get().text();
/* 162 */       if ((txt == null) || (txt.trim().length() == 0)) {
/* 163 */         return null;
/*     */       }
/* 165 */       txt = txt.trim();
/* 166 */       if ("1".equals(txt)) {
/* 167 */         this.localIP = ip;
/* 168 */         this.localPort = port;
/*     */       } else {
/* 170 */         logger.warn("accessId report error : " + txt);
/*     */       }
/* 172 */       return txt;
/*     */     } catch (IOException e) {
/* 174 */       logger.warn(e);
/*     */     }
/*     */ 
/* 177 */     return null;
/*     */   }
/*     */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.manager.ReportLocalInfoManager
 * JD-Core Version:    0.6.1
 */